public class code4_1 {
    //思路2：hashmap
    public int singleNumber(int[] nums) {
        Map<Integer,Integer> hash = new HashMap<>();
        //放元素
        for(Integer i:nums) {
            Integer count = hash.get(i);
            count = (count==null?1:count+1);
            hash.put(i,count);
        }
        //找出现次数为1的元素
        for(Integer x:hash.keySet())
            if(hash.get(x)==1) return x;

        return -1;
    }
}
